//
//  DoctorListCell.m
//  International_Hospital
//
//  Created by 李建强 on 16/7/7.
//  Copyright © 2016年 LiYiLin. All rights reserved.
//

#import "DoctorListCell.h"
#import "DoctorListModel.h"
#import <UIImageView+WebCache.h>


@interface DoctorListCell()
//@property (nonatomic,strong)UIView *bgView;
@property (nonatomic,strong)UIView *grayView;

@property (nonatomic,strong)UIImageView *picImageView;

@property (nonatomic,strong)IH_Label *nameLabel;

@property (nonatomic,strong)IH_Label *profLabel;

@property (nonatomic,strong)IH_Label *hospitalLabel;

@property (nonatomic,strong)UIImageView *addImageView;

@property (nonatomic,strong)IH_Label *addLabel;
@property (nonatomic,strong)UIImageView *qiImageView;

@property (nonatomic,strong)IH_Label *qiLabel;
@property (nonatomic,strong)UIImageView *flowerImageView;
@property (nonatomic,strong)IH_Label *flowerLabel;


@property (nonatomic,strong)UIImageView *pipeiImageView;

@property (nonatomic,strong)UIView *smallView;

@property (nonatomic,strong)UILabel *satLabel;

@property (nonatomic,strong)UIView* sView;




@end

@implementation DoctorListCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
        [self setupLayout];

//        self.picImageView.layer.cornerRadius = self.picImageView.frame.size.width/2;
        
        
    }
    return self;
}



-(void)setupUI{
    
//    self.bgView = [[UIView alloc]init];
    
    self.sView = [[UIView alloc]init];
    
    self.sView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    

    self.picImageView = [[UIImageView alloc]init];

    
    
//    self.picImageView.backgroundColor = [UIColor redColor];
    
    self.pipeiImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"pipeidu"]];
    
    self.picImageView.layer.cornerRadius = 40;
    
    self.picImageView.layer.masksToBounds = YES;
    
    
    self.nameLabel = [[IH_Label alloc]init];
    
    
    
    
    self.nameLabel.textColor = [UIColor blackColor];
    
    self.profLabel = [[IH_Label alloc]init];
    
    self.profLabel.textColor = [UIColor lightGrayColor];
    self.profLabel.font = [UIFont systemFontOfSize:14];
    
    self.hospitalLabel = [[IH_Label alloc]init];
    
    self.hospitalLabel.textColor = [UIColor lightGrayColor];
    self.hospitalLabel.font = [UIFont systemFontOfSize:14];
    self.flowerImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"xianhua"]];
    
    self.flowerLabel = [IH_Label labelWithTitel:@"100" withColor:[UIColor colorWithRed:44/255.0 green:188/255.0 blue:185/255.0 alpha:1] addFont:[UIFont systemFontOfSize:14]];
    
    self.addLabel = [IH_Label labelWithTitel:@"100" withColor:[UIColor colorWithRed:44/255.0 green:188/255.0 blue:185/255.0 alpha:1] addFont:[UIFont systemFontOfSize:14]];
    self.addImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"yuyueliang"]];
    
    self.qiImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"jinqi"]];
    self.qiLabel = [IH_Label labelWithTitel:@"100" withColor:[UIColor colorWithRed:44/255.0 green:188/255.0 blue:185/255.0 alpha:1] addFont:[UIFont systemFontOfSize:14]];
    
    
    self.smallView = [[UIView alloc]init];
    
    self.smallView.backgroundColor = kThemeColor;
    
    self.satLabel = [[IH_Label alloc]init];
    self.satLabel.font = [UIFont systemFontOfSize:10];
    self.satLabel.textColor = [UIColor whiteColor];
    self.satLabel.numberOfLines = 0;
    self.satLabel.textAlignment = NSTextAlignmentCenter;

    
    
    [self.contentView addSubview:self.picImageView];
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.profLabel];
    [self.contentView addSubview:self.hospitalLabel];
    [self.contentView addSubview:self.flowerImageView];
    [self.contentView addSubview:self.flowerLabel];
    [self.contentView addSubview:self.addImageView];
    [self.contentView addSubview:self.addLabel];
    [self.contentView addSubview:self.qiImageView];
    [self.contentView addSubview:self.qiLabel];
    
    [self.contentView addSubview:self.pipeiImageView];
    [self.pipeiImageView addSubview:self.satLabel];
    
    [self.contentView addSubview:self.sView];
    [self.sView addSubview:self.smallView];
    
    
    
}

-(void)setupLayout{

    
    [self.sView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.contentView).offset(0);
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(10);
    }];
    

    [self.satLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.pipeiImageView.mas_top);
        make.left.right.equalTo(self.pipeiImageView);
        make.height.equalTo(self.pipeiImageView);
        
    }];
    
    
    
    
    
    
    [self.picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.sView.mas_bottom).offset(15);
        make.left.equalTo(self.contentView).offset(15);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(80);
        
    }];
    

    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.picImageView.mas_top).offset(10);
        make.left.equalTo(self.picImageView.mas_right).offset(10);
        
        
    }];
    
    [self.profLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.picImageView.mas_top).offset(10);
        make.left.equalTo(self.nameLabel.mas_right).offset(10);
        
    }];
    
    [self.hospitalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.profLabel.mas_bottom).offset(10);
        make.left.equalTo(self.picImageView.mas_right).offset(10);
    }];
    
    [self.addImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.hospitalLabel);
        make.top.equalTo(self.hospitalLabel.mas_bottom).offset(10);
        make.height.equalTo(self.addImageView.mas_height);
        make.width.equalTo(self.addImageView.mas_width);
        
    }];
    
    [self.addLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.addImageView.mas_top).offset(-1.5);
        make.left.equalTo(self.addImageView.mas_right).offset(5);
        
    }];
    
    
    
    
    
    [self.flowerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.addImageView.mas_top);
        make.left.equalTo(self.addLabel.mas_right).offset(20);
        make.height.equalTo(self.flowerImageView.mas_height);
        make.width.equalTo(self.flowerImageView.mas_width);
        
    }];
    [self.flowerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.flowerImageView.mas_top).offset(-1.5);
        make.left.equalTo(self.flowerImageView.mas_right).offset(5);
    }];
    
    
    
    [self.qiImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        
        make.left.equalTo(self.flowerLabel.mas_right).offset(20);
        make.top.equalTo(self.flowerImageView.mas_top);
        make.height.equalTo(self.qiImageView.mas_height);
        make.width.equalTo(self.qiImageView.mas_width);
        
        
    }];
    
    [self.qiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.qiImageView.mas_right).offset(5);
        make.top.equalTo(self.qiImageView.mas_top).offset(-2);
        
    }];
    
    
    [self.pipeiImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.right.equalTo(self.contentView.right).offset(-20);
        make.top.equalTo(self.sView.mas_bottom).offset(0);
        make.width.equalTo(self.pipeiImageView.frame.size.width);
        make.height.equalTo(self.pipeiImageView.frame.size.height);
    }];
    
    
    [self.smallView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(5);
        make.right.equalTo(self.contentView.mas_right).offset(-20);
        make.height.mas_equalTo(5);
        make.width.equalTo(self.pipeiImageView.mas_width);
        
    }];
    
    
    
}
-(void)setModel:(DoctorListModel *)model{
    
    _model = model;
    
    self.banner = model.banner;
    
//    if (model.banner.intValue == 0) {
//      self.picImageView.image = [UIImage imageNamed:@"illness_img_person.png"];
//    }else{
    [self.picImageView sd_setImageWithURL:[NSURL URLWithString:model.doctor_portrait] placeholderImage:[UIImage imageNamed:@"illness_img_person.png"]];
        
//    }
    
    
    
    self.nameLabel.text = model.doctor_name;
    
    self.profLabel.text = model.doctor_title_name;
    
    self.hospitalLabel.text = model.doctor_hospital_name;
    
    self.satLabel.text = [NSString stringWithFormat:@"匹配度:%d%%",model.accuracy.intValue];
    
    CGFloat height = self.picImageView.frame.size.height +20;
    self.cellHeight = height;
    
    
    
    
}





-(void)layoutSubviews{
    
    [super layoutSubviews];
    
    
}



@end
